package main

import (
	"fmt"
	"gin_api_demo/configs"
	//"gin_api_demo/configs"
	"gin_api_demo/dal"
	"gin_api_demo/logger"
	"gin_api_demo/router"
	"go.uber.org/zap"
)

func main() {

	// 1. 加载配置viper
	//configs.InitConfig()
	err := configs.InitConfig()
	if err != nil {
		panic(err)
	}
	fmt.Println(configs.Conf.Name + " " + configs.Conf.Version + " " + configs.Conf.Mode)

	// 2.初始化日志模块zap
	err = logger.Init()
	if err != nil {
		panic(err)
	}
	defer zap.L().Sync()
	zap.L().Info("app start")

	// 3. 数据库初始化
	dal.Init()

	// 4. 初始化路由
	r := router.Setup()

	// 5. 程序启动
	err = r.Run(configs.Conf.Address)
	if err != nil {
		panic(err)
	}

}
